using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Universal.Domain.Entities.App;

namespace Universal.Infrastructure.DB.Config;

public class AppArticleCategoryConfiguration : IEntityTypeConfiguration<AppArticleCategory>
{
    public void Configure(EntityTypeBuilder<AppArticleCategory> builder)
    {
        // 自引用一对多：文章分类的父子结构
        builder
            .HasOne(c => c.Parent)
            .WithMany(c => c.Children)
            .HasForeignKey(c => c.ParentId);
    }
}